package com.sunny.client.loadbalance;

import java.util.List;
import java.util.Random;

/**
 * 负载均衡随机算法
 *
 * @author Sunny
 * @date 2020/2/16
 */
public class RandomLoadBalance extends AbstractLoadBalance {

    @Override
    protected String doSelectHost(List<String> address) {
        int length = address.size();
        Random random = new Random();
        //从服务地址的集合内容随机获得一个地址
        return address.get(random.nextInt(length));
    }
}
